package cn.jilian.dao.support;

import javax.persistence.AttributeConverter;

import org.apache.commons.lang3.StringUtils;


public class BooleanConverter implements AttributeConverter<String, Integer> {

	@Override
	public Integer convertToDatabaseColumn(String attribute) {
		if(StringUtils.equalsIgnoreCase("on", attribute)) {
			return 1;
		}else {
			return 0;
		}
		
	}

	@Override
	public String convertToEntityAttribute(Integer dbData) {
		return dbData==1?"on":"off";
	}

	

}
